package com.itboye.shopcar_adapter;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;

import com.itboye.mengwu.R;
import com.itboye.mengwu.data.model.WithdrawalsBean;
import com.itboye.mengwu.data.model.WithdrawalsBean.A;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class HistoryAdapter extends BaseAdapter {
	Context context;
	List<A> list;

	public HistoryAdapter(Context context, List<A> list2) {
		this.context = context;
		this.list = list2;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return list == null ? 0 : list.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		HoderView houder;
		if (convertView == null) {
			houder = new HoderView();
			convertView = LayoutInflater.from(context).inflate(
					R.layout.item_history, null);
			houder.txtWithdrawals = (TextView) convertView
					.findViewById(R.id.txtWithdrawals);
			houder.txthistoryTime = (TextView) convertView
					.findViewById(R.id.txthistoryTime);
			houder.txthandle = (TextView) convertView
					.findViewById(R.id.txthandle);
			houder.txthistorymoney = (TextView) convertView
					.findViewById(R.id.txthistorymoney);
			convertView.setTag(houder);
		} else {
			houder = (HoderView) convertView.getTag();
		}
		houder.txtWithdrawals.setText(list.get(position).getReason());
		houder.txthistoryTime.setText(new SimpleDateFormat("yyyy-MM-dd").format(Long
				.parseLong(list.get(position).getCreateTime())*1000));
		if (list.get(position).getValidStatus().equals("0")) {
			houder.txthandle.setText("处理中");
			houder.txthistorymoney.setText("￥" + list.get(position).getMoney());
		} else if (list.get(position).getValidStatus().equals("1")) {
			houder.txthandle.setText("提现成功");
			houder.txthistorymoney
					.setText("-￥" + list.get(position).getMoney());
		}
		if (list.get(position).getValidStatus().equals("2")) {
			houder.txthandle.setText("您的提现被驳回");
			houder.txthistorymoney.setText("￥" + list.get(position).getMoney());
		} else {

		}

		return convertView;
	}

	class HoderView {
		private TextView txtWithdrawals;
		private TextView txthistoryTime;
		private TextView txthandle;
		private TextView txthistorymoney;
	}

}
